FROM {{ namespace }}/{{ infra_image_prefix }}base:{{ tag }}
{% block labels %}
LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build_date }}"
{% endblock %}

{% block logstash_header %}{% endblock %}

{% import "macros.j2" as macros with context %}

{{ macros.configure_user(name='logstash', shell='/bin/bash', homedir='/usr/share/logstash') }}

{{ macros.enable_extra_repos(['logstash']) }}

{% if base_package_type == 'rpm' %}
    {% set elk_java_package = 'java-11-openjdk-headless' %}
ENV JAVA_HOME /usr/lib/jvm/jre-11-openjdk/
{% elif base_package_type == 'deb' %}
    {% set elk_java_package = 'openjdk-11-jre-headless' %}
ENV JAVA_HOME /usr/lib/jvm/java-11-openjdk-{{debian_arch}}/
{% endif %}

{% set logstash_packages = [
    'logstash-oss',
] %}

# Post-install script of Logstash fails when trying to install Logstash and
# Java together.
{{ macros.install_packages([elk_java_package]) }}
{{ macros.install_packages(logstash_packages | customizable("packages")) }}
COPY extend_start.sh /usr/local/bin/kolla_extend_start

RUN chmod 755 /usr/local/bin/kolla_extend_start

{% block logstash_footer %}{% endblock %}
{% block footer %}{% endblock %}

USER logstash
